/*
 * @Author: zhang ke
 * @Date: 2025-07-05 15:44:13
 * @LastEditors: your name
 * @LastEditTime: 2025-07-05 16:45:50
 * @Description: 
 * @FilePath: \vue3-admin\src\directive\has.ts
 */
/*
 * @Author: zhang ke
 * @Date: 2025-07-05 15:44:13
 * @LastEditors: your name
 * @LastEditTime: 2025-07-05 15:57:38
 * @Description: 
 * @FilePath: \vue3-admin\src\directive\has.ts
 */
import pinia from "@/store";
import useUserStore from "@/store/modules/user";
//获取用户仓库
const userStore = useUserStore(pinia)
export const isHasButton = (app:any)=>{
    // 全局自定义指令：实现按钮的权限
    app.directive('has',{
        //代表使用这个全局自定义指令的DOM|组件挂载完毕的时候会执行一次
        mounted(el:any,options:any){
            // 自定义指令右侧的数值：如果用户信息buttons数组当中没有，就从Dom树上干掉
            if(!userStore.buttons.includes(options.value)){
                el.parentNode.removeChild(el)
            }
        }
    })
}